<?php

/* 
 * synthese/index.phtml
 */
$title = "Synthèse de Paie";
$this->headTitle($title);
$site = $this->site;
$periode = $this->periode;
?>
<form class="hide" id="form-data" action="#" method="get">
    <input type="hidden" id="form-site" name="site" value="<?php echo $site->id; ?>">
    <input type="hidden" id="form-periode" name="periode" value="<?php echo $periode->id; ?>">
</form>
<div class="content-head">
    <h3>
	<?php echo $title; ?> pour le site <a href="#" id="site" data-type="select"><?php echo $site->libelle; ?></a> Période : <a href="#" id="periode" data-type="select"><?php echo $periode->libelle; ?></a>
	<span id="ajax-loader" class="hide" style="margin-left: 10px;">
	    <img src="<?php echo $this->basePath();?>/img/rhx/ajax-loader.gif" width="32" height="32">
	</span>
    </h3>
</div>
<div class="content-body">
    <div id="content-data">
	<?php echo $this->loadIndex; ?>
    </div>
</div>

<script type="text/javascript">
    $(function(){
	$('#site').editable({
	    title: "Sites",
	    source: "<?php echo $this->url('RHX/default', array('controller'	 => 'synthese', 'action'	 => 'siteList')) ?>",
	    validate: function(value){
		val = value - 1;
		//alert(val);
		$('#form-site').val(val);
		if(val < 0){
		    loadTotal();
		    return;
		}
		changeSite(val);
		refresh();
	    }
	});
	$('#periode').editable({
	    title: "Période",
	    source: "<?php echo $this->url('RHX/default', array('controller'	 => 'variable', 'action'	 => 'jsonPeriodeList')) ?>",
	    validate: function(value){
		$('#form-periode').val(value);
		changePeriode(value);
		refresh();
	    }
	});
    });
    function refresh(){
	$('#content-data').fadeOut('normal');
	$('#ajax-loader').show('normal');
	$ajax = $.ajax({
	    type: 'post',
	    url : '<?php echo $this->url('RHX/default', array('controller' => 'synthese', 'action' => 'loadIndex')) ?>',
	    data: $('#form-data').serialize()
	});
	$ajax.done(function(data){
	    $('#ajax-loader').hide('normal');
	    $('#content-data').html(data).fadeIn('normal');
	});
    }
    function loadTotal(){
	$('#content-data').fadeOut('normal');
	$('#ajax-loader').show('normal');
	$ajax = $.ajax({
	    type: 'post',
	    url : '<?php echo $this->url('RHX/default', array('controller' => 'synthese', 'action' => 'loadTotal')) ?>',
	    data: $('#form-data').serialize()
	});
	$ajax.done(function(data){
	    $('#ajax-loader').hide('normal');
	    $('#content-data').html(data).fadeIn('normal');
	});
    }
</script>